function getL(){
	$("#tab>tr").remove()
	var data=$("#point").val()
	console.log(data)
	$.ajax({
		"url":"/handover/",
		"error":errorAjax,
		"beforeSend":start_load_pic,
		"complete":stop_load_pic,
		"dataType":"jsonp",
		"data":{"data":data},
		"success":function(data){
			if(responseCheck(data)){
				$("#name").text(data.name)
				// test
				$("#charge_total").text("￥"+data.charge_all.toFixed(2))
				$("#charge_cash").text("￥"+data.charge_cash.toFixed(2))
				$("#charge_code").text("￥"+data.charge_code.toFixed(2)+" )") 
				$("#handover_date").text("交班时间: "+data.handover_date)
				$("#print_date").text("打印时间: "+data.print_date)
				$("#name").text(data.name)
				$("#site").text(data.site)
				$("#consumption").text("￥"+data.consumption.toFixed(2))
				$("#all").text("￥"+data.all.toFixed(2))
				var tab=document.getElementById("tab")
				var l=["92","95","98","0","lng","电"]
				for (var i=0 ; i<l.length;i++){
					var oil=l[i]
					console.log(oil)
					var tr=document.createElement("tr")
					var td=document.createElement("td")
					td.textContent=oil.toUpperCase()+" #"
					tr.appendChild(td)
					
					var td=document.createElement("td")
					if(data.content[oil]===undefined){
						data.content[oil]={
							"capacity":0,
							"cash":0,
							"weichat":0,
							"zhifu":0,
							"online":0,
							"all":0,
							"shuaka":0,
							"jizhang":0,
							"tuanyou":0,
						}
					}
					td.textContent=data.content[oil].capacity.toFixed(2)
					tr.appendChild(td)


					var td=document.createElement("td")
					td.textContent=data.content[oil].all.toFixed(2)
					tr.appendChild(td)

					var td=document.createElement("td")
					td.textContent=data.content[oil].weichat.toFixed(2)
					tr.appendChild(td)

					var td=document.createElement("td")
					td.textContent=data.content[oil].zhifu.toFixed(2)
					tr.appendChild(td)

					var td=document.createElement("td")
					td.textContent=data.content[oil].online.toFixed(2)
					tr.appendChild(td)

					var td=document.createElement("td")
					td.textContent=data.content[oil].cash.toFixed(2)
					tr.appendChild(td)

					var td=document.createElement("td")
					td.textContent=data.content[oil].shuaka.toFixed(2)
					tr.appendChild(td)

					var td=document.createElement("td")
					td.textContent=data.content[oil].jizhang.toFixed(2)
					tr.appendChild(td)

					var td=document.createElement("td")
					td.textContent=data.content[oil].tuanyou.toFixed(2)
					tr.appendChild(td)


					tab.appendChild(tr)

				}
				//合计栏目
				var tr=document.createElement("tr")
				tr.style.cssText="font-size:110%;font-weight:bold;"
				var td=document.createElement("td")
				td.textContent="合计"
				tr.appendChild(td)

				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(1)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(2)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(3)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(4)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(5)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(6)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(7)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(8)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)
				var td=document.createElement("td")
				var v=0
				$("#tab>tr").each(function(){
					t= $(this).find("td:eq(9)").text()
					v+= parseFloat(t)
				})
				td.textContent=v.toFixed(2)
				tr.appendChild(td)

				tab.appendChild(tr)
				
				
				
			}
		}
	})
}
//getL()
function getPoint(){
	//获取班口列表
	$.ajax({
		"url":"/handover_list/",
		"beforeSend":start_load_pic,
		"complete":stop_load_pic,
		"error":errorAjax,
		"dataType":"jsonp",
		"success":function(data){
			if(responseCheck(data)){
				var select=document.getElementById("point")
				for(var i=0;i<data.content.length;i++){
					var option=document.createElement("option")
					for (var key in data.content[i]){
						option.textContent=key
						option.value=data.content[i][key]
						// 只有一行记录
					}
					select.appendChild(option)
				}
				if(data.content.length===0){
					showErrorInfo("当前还没有交班记录，不能查询！")
					return false;
				}
				else{
					//默认选中最后一个
					$(select).val(data.content[i-1][key])
					getL()
				}
			}
		}
	})
}
document.getElementById("point").onchange=function(){
	getL()
}
document.getElementById("print").onclick=function(){
	print()
}
getPoint()
